<template>
  <div class="box">
      <h1>我是收藏</h1>
      <div class="bar">
          <div @click="handler(item.state)" :class="['item',item.isActive? 'is-active' : '']"  v-for="item in list" :key="item.id">
              <span class="item-icon" :class="item.icon"></span>
              <span>{{ item.label }}</span>
          </div>
      </div>
  </div>
</template>

<script setup>
import { ref } from 'vue';
import { nanoid } from 'nanoid';

import {useRouter, useRoute} from 'vue-router';

// 获取路由对象
const router = useRouter();

const list = ref([
  {
      id:nanoid(4),
      label:'购物车',
      icon:'fas fa-cat',
      isActive:false,
      state:'/Shoppingcart'
  },
  {
      id:nanoid(4),
      label:'收 藏',
      icon:'fas fa-dove',
      isActive:true,
      state:'/collect'
  },
  {
      id:nanoid(4),
      label:'首 页',
      icon:'fas fa-dragon',
      isActive:false,
      state:'/home'
  },
  {
      id:nanoid(4),
      label:'设 置',
      icon:'fas fa-horse',
      isActive:false,
      state:'/set'
  },
  {
      id:nanoid(4),
      label:'我 的',
      icon:'fas fa-spider',
      isActive:false,
      state:'/mine'
  },
])

const handler = _state => {
  router.replace(_state);
}


</script>

<style lang="scss" scoped>
.box {
  width: 100%;
  height: 200vh;
}

.bar {
  // 放置在下面
  position: fixed;
  bottom: 0px;

  //
  display: flex;
  justify-content: space-evenly;
  align-items: center;

  width: 100%;
  height: 100px;
  box-shadow: 0px 0px 10px rgba($color: #534d4d, $alpha: 0.3);
}

.is-active {
  color: aqua;
}

.item {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;

  padding: 15px;
      &-icon {
          font-size: 25px;
      }
}


</style>